package com.dam.monngonmoingay;

import com.dam.monngonmoingay.R;
import com.startapp.android.publish.StartAppSDK;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;

public class MainActivity extends Activity implements OnClickListener {

	MonNgonDB db;
	TextView nglieu, tenmon, meovat, cachthuc;
	String TAG = "MainActivity";
	ImageButton ngayThuongImageButton, dacBietImageButton, choBeImageButton,
			monChayImageButton, yeuThichImageButton, settingButton;
	Button setting;



	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.menu_main);
		ngayThuongImageButton = (ImageButton) findViewById(R.id.hangngayButton);
		dacBietImageButton = (ImageButton) findViewById(R.id.dacbietButton);
		choBeImageButton = (ImageButton) findViewById(R.id.beyeuButton);
		monChayImageButton = (ImageButton) findViewById(R.id.monchayButton);
		yeuThichImageButton = (ImageButton) findViewById(R.id.yeuthichButton);

		//settingButton = (ImageButton) findViewById(R.id.settingButton);
		//registerForContextMenu(settingButton);

		ngayThuongImageButton.setOnClickListener(this);
		dacBietImageButton.setOnClickListener(this);
		choBeImageButton.setOnClickListener(this);
		monChayImageButton.setOnClickListener(this);
		yeuThichImageButton.setOnClickListener(this);

		StartAppSDK.init(this, DeveloperKey.DEVELOPER_STARTAPP_DEVELOPER_ID, DeveloperKey.DEVELOPER_STARTAPP_ID, true);
	}
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.hangngayButton:
			open(1);
			break;
		case R.id.dacbietButton:
			open(2);
			break;
		case R.id.beyeuButton:
			open(3);
			break;
		case R.id.monchayButton:
			open(4);
			break;
		case R.id.yeuthichButton:
			open(5);
			break;
		}
	}

	public void open(int id) {
		Intent myIntent = new Intent(this, ListMonAnActivity.class);
		Bundle bundle = new Bundle();
		bundle.putInt("id", id);
		MonNgonApplication app = (MonNgonApplication) getApplicationContext();
		app.setLastCatalogId(id);
		myIntent.putExtra("id", bundle);
		startActivity(myIntent);

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// TODO Auto-generated method stub
		return true;

	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// TODO Auto-generated method stub
		return super.onOptionsItemSelected(item);
	}

	
	
	@Override
	public void onCreateContextMenu(ContextMenu menu, View v,
			ContextMenuInfo menuInfo) {
		// TODO Auto-generated method stub
		super.onCreateContextMenu(menu, v, menuInfo);
	}

	@Override
	public boolean onContextItemSelected(MenuItem item) {
		return super.onContextItemSelected(item);
	}
}
